package com.kuang.dao;


import com.kuang.pojo.User;
import org.mybatis.spring.SqlSessionTemplate;

import java.util.List;

/**增加 Dao接口的实现类，私有化sqlSessionTemplate
 * @author FHL
 */
public class UserDaoImpl implements UserMapper {
    //sqlSession不用再自己创建了，由Spring来管理
private SqlSessionTemplate sqlSession;
public void setSqlSessionTemplate(SqlSessionTemplate sqlSession) {
    this.sqlSession=sqlSession;
}
    public List<User> selectUsers() {
        UserMapper mapper = sqlSession.getMapper(UserMapper.class);
       return mapper.selectUsers();
    }
    public int addUser(User user) {
        return sqlSession.getMapper(UserMapper.class).addUser(user);
    }

    public int delete(int id) {
        return sqlSession.getMapper(UserMapper.class).delete(id);
    }

}
